package com.quasar.hpatient.bean.home_medicine_oral;

import android.text.TextUtils;

import lib.quasar.util.LogUtil;
import lib.quasar.util.SpannableUtil;

public final class MedicineOralItemBean {

    private String mname = "";
    private String dosename = "";
    private String time = "";
    private int number;

    public CharSequence getMname() {

        if (TextUtils.isEmpty(mname) || mname.length() <= 7)
            return mname;

        for (int i = 0; i < mname.length(); i += 6) {
            int end = i + 6;
            if (end > mname.length()) {
                end = mname.length();
            }
            final String temp = mname.substring(i, end);
            SpannableUtil.append(temp);
            if (end != mname.length()) {
                SpannableUtil.newline();
            }
        }
        return SpannableUtil.build();
    }

    public void setMname(String mname) {
        this.mname = mname;
    }

    public String getDosename() {
        return dosename;
    }

    public void setDosename(String dosename) {
        this.dosename = dosename;
    }

    public String getTime() {

        try {
            if (time.length() == 8) {
                return time.substring(0, 5);
            } else {
                return time;
            }
        } catch (Exception e) {
            LogUtil.e("", e.getMessage(), e);
            return "未知时间";
        }
    }

    public void setTime(String time) {
        this.time = time;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}
